//
//  YJTasklistCell.m
//  YJB
//
//  Created by YJB on 2016/11/25.
//  Copyright © 2016年 YJB. All rights reserved.
//

#import "THTasklistCell.h"
#import "masonry.h"
#import "THTasklistModel.h"

@interface THTasklistCell ()
@property(nonatomic,strong)UILabel  *titleLab;
@property(nonatomic,strong)UILabel  *taskTotal;
@property(nonatomic,strong)UILabel  *taskComplete;
@property(nonatomic,strong)UILabel  *urlLab;
@end

NSString *const tasklistCellID = @"YJTasklistCell";
@implementation THTasklistCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        UIView *line = [[UIView alloc]init];
        line.backgroundColor = kUIColorFromRGB(0xcccccc);
        [self addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.mas_equalTo(0);
            make.height.mas_equalTo(0.5);
        }];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

-(UILabel *)titleLab
{
    if (_titleLab == nil)
    {
        _titleLab = [[UILabel alloc]init];
        _titleLab.backgroundColor = WHITECOLOR;
        _titleLab.textAlignment = NSTextAlignmentCenter;
        _titleLab.font = FONT(15);
        _titleLab.numberOfLines = 0;
        _titleLab.textColor = kUIColorFromRGB(0x333333);
        [self addSubview:_titleLab];
        [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.bottom.mas_equalTo(-0.5);
            make.left.mas_equalTo(12);
            make.width.mas_equalTo(12.7 * GRIDW - 12);
        }];
    }
    return _titleLab;
}

-(UILabel *)taskTotal
{
    if (_taskTotal == nil)
    {
        _taskTotal = [[UILabel alloc]init];
        _taskTotal.backgroundColor = kUIColorFromRGB(0xeeeeee);
        _taskTotal.font = FONT(15);
        _taskTotal.textAlignment = NSTextAlignmentCenter;
        _taskTotal.numberOfLines = 0;
        _taskTotal.textColor = kUIColorFromRGB(0xfa5f3c);
        [self addSubview:_taskTotal];
        [_taskTotal mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.bottom.mas_equalTo(-0.5);
            make.left.mas_equalTo(self.titleLab.mas_right);
            make.width.mas_equalTo(6 * GRIDW);
        }];
    }
    return _taskTotal;
}

-(UILabel *)taskComplete
{
    if (_taskComplete == nil)
    {
        _taskComplete = [[UILabel alloc]init];
        _taskComplete.backgroundColor = WHITECOLOR;
        _taskComplete.font = FONT(15);
        _taskComplete.textAlignment = NSTextAlignmentCenter;
        _taskComplete.numberOfLines = 0;
        _taskComplete.textColor = kUIColorFromRGB(0xfa5f3c);
        [self addSubview:_taskComplete];
        [_taskComplete mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.bottom.mas_equalTo(-0.5);
            make.left.mas_equalTo(self.taskTotal.mas_right);
            make.width.mas_equalTo(6 * GRIDW);
        }];
    }
    return _taskComplete;
}

-(UILabel *)urlLab
{
    if (_urlLab == nil)
    {
        _urlLab = [[UILabel alloc]init];
        _urlLab.numberOfLines = 0;
        _urlLab.backgroundColor = kUIColorFromRGB(0xeeeeee);
        _urlLab.font = FONT(15);
        _urlLab.textAlignment = NSTextAlignmentCenter;
        _urlLab.textColor = kUIColorFromRGB(0x333333);
        [self addSubview:_urlLab];
        [_urlLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.bottom.mas_equalTo(-0.5);
            make.left.mas_equalTo(self.taskComplete.mas_right);
            make.right.mas_equalTo(0);
        }];
    }
    return _urlLab;
}

-(void)setModel:(THTasklistModel *)model
{
    self.titleLab.text = model.title;
    self.taskTotal.text = model.taskCount.length?model.taskCount:@"0";
    self.taskComplete.text = model.surfedcount.length?model.surfedcount:@"0";
    self.urlLab.text = model.url;
}


@end
